home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / emacs.lha / emacs-19.16 / lisp / forms-d2.el < prev    next >
Lisp/Scheme  |  1993-07-02  |  2KB  |  86 lines

  1. ;; demo2 -- demo forms-mode    -*- emacs-lisp -*-
  2.  
  3. ;; SCCS Status     : @(#)@ demo2    1.1.2
  4. ;; Author          : Johan Vromans
  5. ;; Created On      : 1989
  6. ;; Last Modified By: Johan Vromans
  7. ;; Last Modified On: Mon Jul  1 13:56:31 1991
  8. ;; Update Count    : 2
  9. ;; Status          : OK
  10. ;; 
  11. ;; This sample forms exploit most of the features of forms mode.
  12.  
  13. ;; Set the name of the data file.
  14. (setq forms-file "forms-d2.dat")
  15.  
  16. ;; Use 'forms-enumerate' to set field names and number thereof.
  17. (setq forms-number-of-fields
  18.       (forms-enumerate
  19.        '(arch-newsgroup            ; 1
  20.      arch-volume            ; 2
  21.      arch-issue            ; and ...
  22.      arch-article            ; ... so
  23.      arch-shortname            ; ... ... on
  24.      arch-parts
  25.      arch-from
  26.      arch-longname
  27.      arch-keywords
  28.      arch-date
  29.      arch-remarks)))
  30.  
  31. ;; The following functions are used by this form for layout purposes.
  32. ;;
  33. (defun arch-tocol (target &optional fill)
  34.   "Produces a string to skip to column TARGET. Prepends newline if needed.
  35. The optional FILL should be a character, used to fill to the column."
  36.   (if (null fill)
  37.       (setq fill ? ))
  38.   (if (< target (current-column))
  39.       (concat "\n" (make-string target fill))
  40.     (make-string (- target (current-column)) fill)))
  41. ;;
  42. (defun arch-rj (target field &optional fill) 
  43.   "Produces a string to skip to column TARGET minus the width of field FIELD.
  44. Prepends newline if needed. The optional FILL should be a character,
  45. used to fill to the column."
  46.   (arch-tocol (- target (length (nth field forms-fields))) fill))
  47.  
  48. ;; Record filters.
  49. ;; This example uses the (defun ...) method of defining.
  50. ;;
  51. (defun forms-new-record-filter (the-record)
  52.   "Form a new record with some defaults."
  53.   (aset the-record arch-from (user-full-name))
  54.   (aset the-record arch-date (current-time-string))
  55.   the-record                ; return it
  56. )
  57.  
  58. ;; The format list.
  59. (setq forms-format-list
  60.      (list
  61.        "====== Public Domain Software Archive ======\n\n"
  62.        arch-shortname
  63.        " - "            arch-longname
  64.        "\n\n"
  65.        "Article: "        arch-newsgroup
  66.        "/"            arch-article
  67.        " "
  68.        '(arch-tocol 40)
  69.        "Issue: "        arch-issue
  70.        " "
  71.        '(arch-rj 73 10)
  72.        "Date: "            arch-date
  73.        "\n\n"
  74.        "Submitted by: "        arch-from
  75.        "\n"
  76.        '(arch-tocol 79 ?-)
  77.        "\n"
  78.        "Keywords: "        arch-keywords
  79.        "\n\n"
  80.        "Parts: "        arch-parts
  81.        "\n\n====== Remarks ======\n\n"
  82.        arch-remarks
  83.      ))
  84.  
  85. ;; That's all, folks!
  86.